package com.fz.us.oa.core.service.com.impl;

import com.fz.us.admin.company.dao.BaseFlowDao;
import com.fz.us.admin.company.entity.*;
import com.fz.us.admin.company.service.impl.BaseFlowServiceImpl;
import com.fz.us.oa.core.dao.com.PersonnelInfoDao;
import com.fz.us.oa.core.entity.com.PersonnelInfo;
import com.fz.us.oa.core.service.com.PersonnelInfoService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by ZhuChunXiao on 2017/7/14.
 */
@Service
public class PersonnelInfoServiceImpl extends BaseFlowServiceImpl<PersonnelInfo,String> implements PersonnelInfoService {
    @Resource
    PersonnelInfoDao personnelInfoDao;

    @Override
    public BaseFlowDao<PersonnelInfo, String> getBaseFlowDao() {
        return personnelInfoDao;
    }

    @Override
    public Power getPowerByDepartmentAndPost(Department department, Post post) {
        return personnelInfoDao.getPowerByDepartmentAndPost(department,post);
    }

    @Override
    public Map<String, Object> getTreeMap(Power power) {
        HashMap map = new HashMap();
        map.put("id", StringUtils.isEmpty(power.getPost().getId())?"":power.getPost().getId());
        map.put("name", StringUtils.isEmpty(power.getPost().getName())?"":power.getPost().getName());
        return map;
    }

    @Override
    public List<Power> getPowerByDepartment(Department department) {
        return personnelInfoDao.getPowerByDepartment(department);
    }

    @Override
    public Duty getDutyByPowerAndUser(Power power, User user) {
        return personnelInfoDao.getDutyByPowerAndUser(power,user);
    }
}
